package com.ymatou.iapi.godmch.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.common.collect.Lists;
import com.ymatou.iapi.godmch.parameter.getSupplierMarkupConfigBean;
import com.ymatou.iapi.godmch.parameter.setConditionLevelBean;
import com.ymatou.iapi.godmch.parameter.setConditionMarkupConfigBean;
import com.ymatou.iapi.godmch.service.getSupplierMarkupConfigCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.utils.TestDataManager;
/**
*获取供货商的加价配置
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getSupplierMarkupConfig{
	private static getSupplierMarkupConfigBean bean;
	private static getSupplierMarkupConfigCall call;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取供货商的加价配置");
	}

	@Before
	public void caseUp() {
		bean=new getSupplierMarkupConfigBean();
		call=new getSupplierMarkupConfigCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getSupplierMarkupConfig_001() {
		Logger.start(true,"获取供货商的加价配置-一个供货商-返回成功");
		try {
			 Integer agentId=GodmchManageCallService.createAgent();
	         Integer supplierId=GodmchManageCallService.createApplySupplier().getSupplierId();
				//新增
	         setConditionMarkupConfigBean setBean=GodmchManageCallService.initSetConditionMarkupConfig(agentId,supplierId);
	         GodmchManageCallService.setConditionMarkupConfigCall(setBean);
	         
	         bean.setAgentId(agentId);
	         bean.setSupplierIdList(Lists.newArrayList(supplierId));
		     call.setData(bean);
			 call.callService();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getSupplierMarkupConfig_002() {
		Logger.start(true,"获取供货商的加价配置-两个供货商-返回成功");
		try {
			 Integer agentId=GodmchManageCallService.createAgent();
	         Integer supplierId=GodmchManageCallService.createApplySupplier().getSupplierId();
	         Integer supplierId2=GodmchManageCallService.createApplySupplier().getSupplierId();
				//新增
	         setConditionMarkupConfigBean setBean=GodmchManageCallService.initSetConditionMarkupConfig(agentId,supplierId);
	         GodmchManageCallService.setConditionMarkupConfigCall(setBean);
	         
	         setBean=GodmchManageCallService.initSetConditionMarkupConfig(agentId,supplierId2);
	         GodmchManageCallService.setConditionMarkupConfigCall(setBean);
	         //设置等级
	         setConditionLevelBean setConditionLevelBean=GodmchManageCallService.initSetConditionLevelBean(agentId,supplierId2);
	         setConditionLevelBean.getList().get(0).setConditionLevel(9);
	         GodmchManageCallService.setConditionLevel(setConditionLevelBean);
	         
	         bean.setAgentId(agentId);
	         bean.setSupplierIdList(Lists.newArrayList(supplierId,supplierId2));
		     call.setData(bean);
			 call.callService();		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getSupplierMarkupConfig_003() {
		Logger.start(true,"获取供货商的加价配置-未设置加价配置-返回空");
		try {
			 Integer agentId=GodmchManageCallService.createAgent();
	         Integer supplierId=GodmchManageCallService.createApplySupplier().getSupplierId();
	         bean.setAgentId(agentId);
	         bean.setSupplierIdList(Lists.newArrayList(supplierId));
	         
		     call.setData(bean);
			 call.callService();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getSupplierMarkupConfig_004() {
		Logger.start(true,"获取供货商的加价配置-代理商与供货商不匹配-返回空");
		try {
			 Integer agentId=GodmchManageCallService.createAgent();
	         Integer supplierId=GodmchManageCallService.createApplySupplier().getSupplierId();
				//新增
	         setConditionMarkupConfigBean setBean=GodmchManageCallService.initSetConditionMarkupConfig(agentId,supplierId);
	         GodmchManageCallService.setConditionMarkupConfigCall(setBean);
	         
	         bean.setAgentId(agentId);
	         bean.setSupplierIdList(Lists.newArrayList(supplierId+11));
		     call.setData(bean);
			 call.callService();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}